from common.basic2 import send_message_to_kafka, upate_meassage_id, save_file, upate_meassage_time
#  报文内容
data = {
    "project": "scan_api",
    "packetType": "http",
    "data": {
        "id": None,
        "agentNodeBusinessMark": "10.10.2.239",
        "httpType": 1,
        "host": "10.10.2.239",
        "port": 32280,
        "httpDirection": None,
        "uri": "/api/system/post",
        "fullUri": "http://10.10.2.239:32280/api/system/post",
        "requestIp": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
        "requestMethod": "POST",
        "requestTime": None,
        "requestTimestamp": None,
        "requestTimestampStr": None,
        "requestContentLength": 32,
        "requestContentType": "application/json",
        "requestHeader": "{\"X-Timestamp\":\"123321\",\"Authorization\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTk0Mzg1ODksInVzZXJuYW1lIjoiYXV0b1Rlc3RfMDEifQ.wEtQlQsvVuluE7c-kJyWSeod7iNCQVgZxQmaVNr3VkM\",\"X-App-Id\":\"ACCO8lMQ\",\"Version\":\"2.0\",\"X-Sequence-No\":\"123321\",\"Connection\":\"keep-alive\",\"User-Agent\":\"Apache-HttpClient/4.5.13 (Java/1.8.0_302)\",\"X-Forwarded-For\":\"10.10.0.10\",\"Host\":\"10.10.2.239:32280\",\"Content-Length\":\"32\",\"Source-Ip\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\",\"Content-Type\":\"application/json\"}",
        "requestBody": "{\"query\":\"select.+(from|limit)\"}",
        "sensitiveChars": None,
        "statusCode": 200,
        "costTime": 1,
        "responseIp": "10.10.2.239",
        "responseTime": "2023-11-08 16:16:30",
        "responseTimestamp": 1699431390887,
        "responseTimestampStr": None,
        "responseContentLength": 15,
        "responseContentType": "application/json",
        "responseHeader": "{\"Transfer-Encoding\":\"chunked\",\"X-mock\":\"true\",\"Destination-Ip\":\"10.10.2.239\",\"Connection\":\"keep-alive\",\"Date\":\"Wed, 08 Nov 2023 08:16:30 GMT\",\"Content-Type\":\"application/json\"}",
        "responseBody": "{\"msg\": \"账号测试\"}",
        "complete": True,
        "hasIllegalAsset": False,
        "illegalReason": "",
        "illegalRule": "",
        "referer": "",
        "userAgent": "Apache-HttpClient/4.5.13 (Java/1.8.0_302)",
        "url": "http://10.10.2.239:32280/api/system/post"
    }
}

# 替换ID
upate_meassage_id(data)

# 替换时间错
upate_meassage_time(data)

# 生成文件
pwd = '../filesOutput/账号-改.txt' # 指定路径
save_file(pwd, data)

# 发送消息到Kafka队列
send_message_to_kafka('10.10.2.236:30519', 'api-neta-parser', data)